﻿namespace BM.Tools.WebControls.MForm.Controls.Additions
{    
    using System.Web.UI;

    /// <summary>
    /// ServiceParameter class keeps data about parameters of the <see cref="ServiceConstraint" />.
    /// The <see cref="ServiceConstraint" /> invokes a service with parameters, each of these parameters has a <see cref="Name" /> 
    /// and a <see cref="Path" /> to the offspring item, whose value will be taken
    /// </summary>
    [System.ComponentModel.DesignTimeVisible(false)]
    public class ServiceParameter : Control
    {        
        private AttributeCollection attributes = new AttributeCollection(new StateBag(true));

        /// <summary>
        /// Gets Attributes.
        /// </summary>
        /// <value>
        /// The attributes.
        /// </value>
        public AttributeCollection Attributes
        {
            get
            {
                return attributes;
            }
        }

        /// <summary>
        /// Gets or sets Name.
        /// </summary>
        /// <value>
        /// The name of the parameter.
        /// </value>
        public string Name
        {
            get
            {
                return Attributes["name"];
            }

            set
            {
                Attributes["name"] = value;
            }
        }

        /// <summary>
        /// Gets or sets Path.
        /// </summary>
        /// <value>
        /// The path of the offspring item.
        /// </value>
        public string Path
        {
            get
            {
                return Attributes["path"];
            }

            set
            {
                Attributes["path"] = value;
            }
        }

        /// <summary>
        /// Renders the control
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render(HtmlTextWriter writer)
        {
            foreach (string key in Attributes.Keys)
            {
                writer.AddAttribute(key, Attributes[key]);
            }

            writer.RenderBeginTag(HtmlTextWriterTag.S);
            writer.RenderEndTag();
        }
    }
}